package com.opensky.qatest.ui.component;

import org.openqa.selenium.By;

import com.opensky.qatest.util.selenium.WebDriverWrapper;

public class JoinPageSignUpForm implements IComponent {

    // ************************ Locators ************************

    public static final String FIRST_NAME_INPUT = "registration_user_firstName";

    public static final String LAST_NAME_INPUT = "registration_user_lastName";

    public static final String EMAIL_INPUT = "registration_user_email";

    public static final String PASSWORD_INPUT = "registration_user_plainPassword";

    private static final String CATEGORIES = "//div[@class='category-follow']";

    private static final String FACEBOOK_LINK = "//a[contains(., 'Log In With Facebook')]";

    private static final String TERMS_LINK = "//div[@class='terms']/label[contains(., 'terms')]";

    public static final String SIGNUP_FORM = "//div[@class='reg-form']/form";

    private static final String START_SHOPPING_BTN = "submit";

    private final WebDriverWrapper driver;

    public JoinPageSignUpForm(WebDriverWrapper driver) {
	this.driver = driver;
    }

    // ************************ Actions **************************

    // ************************ Validations **************************

    @Override
    public boolean isComponentLoaded() {
	return driver.waitAndVerifyElementPresent("SIGNUP_FORM", By.xpath(SIGNUP_FORM));
    }

    public boolean isBaseElementsPresent() {

	driver.waitAndVerifyElementPresent("FIRST_NAME_INPUT", By.id(FIRST_NAME_INPUT));
	driver.waitAndVerifyElementPresent("LAST_NAME_INPUT", By.id(LAST_NAME_INPUT));
	driver.waitAndVerifyElementPresent("FIRST_NAME_INPUT", By.id(FIRST_NAME_INPUT));
	driver.waitAndVerifyElementPresent("FIRST_NAME_INPUT", By.id(FIRST_NAME_INPUT));

	driver.waitAndVerifyElementPresent("CATEGORIES", By.xpath(CATEGORIES));
	driver.waitAndVerifyElementPresent("FACEBOOK_LINK", By.xpath(FACEBOOK_LINK));
	driver.waitAndVerifyElementPresent("TERMS_LINK", By.xpath(TERMS_LINK));
	driver.waitAndVerifyElementPresent("START_SHOPPING_BTN", By.name(START_SHOPPING_BTN));

	return true;
    }

    // ************************ GET/SET methods **************************

    @Override
    public String getName() {
	return "Join page signUp form";
    }
}
